package com.cos.hospital.ui.usercenter;

import android.view.View;
import android.widget.TextView;

import com.cos.hospital.R;
import com.cos.hospital.code.Logic;
import com.cos.hospital.dao.HelperInfoDb;
import com.cos.hospital.dao.beandao.DbInfo;
import com.cos.hospital.init.BaseActivity;
import com.cos.hospital.tool.SPUtil;
import com.cos.hospital.tool.UTxt;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @Description: 我的资料
 * @Author: Kosmos
 * @Date: 2018年9月12日 21:01
 * @Email: KosmoSakura@foxmail.com
 */
public class UserInfoActivity extends BaseActivity {
    @BindView(R.id.info_name)
    TextView tName;
    @BindView(R.id.info_sex)
    TextView tSex;
    @BindView(R.id.info_age)
    TextView tAge;
    @BindView(R.id.info_doctor_number)
    TextView tDoctorNumber;
    @BindView(R.id.info_hospital)
    TextView tHospital;
    @BindView(R.id.info_department)
    TextView tDepartment;

    @Override
    protected int layout() {
        return R.layout.activity_user_info;
    }

    @Override
    protected void init() {
        setTitleLeftIcon();
        setTitleCenterTxt(getString(R.string.info_mine));
    }

    @Override
    protected void logic() {
        DbInfo info = HelperInfoDb.SearchById(this, SPUtil.getUserId());
        if (info != null) {
            tName.setText(UTxt.isNull(info.getNameUser(), "???"));
            tSex.setText(Logic.getSex(info.getCodeSex()));
            tAge.setText(getString(R.string.unit_age, info.getAge()));
            tDoctorNumber.setText(UTxt.isNull(info.getQualification(), "???"));
            tHospital.setText(UTxt.isNull(info.getNameHost(), "???"));
            tDepartment.setText(UTxt.isNull(info.getNameDept(), "???"));
        }
    }

    @OnClick({R.id.title_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_back:
                finish();
                break;
        }
    }

}
